package com.yaowk.web.mall.clothing.controller;

import com.yaowk.api.common.PageReq;
import com.yaowk.api.common.PageResp;
import com.yaowk.api.mall.clothing.service.IOrderService;
import com.yaowk.api.mall.clothing.web.OrderModel;
import com.yaowk.api.mall.clothing.web.OrderQueryModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/mall/clothing/order")
@Api(tags = "订单控制器")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @GetMapping
    @ApiOperation("订单列表")
    public PageResp<OrderModel> list(OrderQueryModel orderQueryModel, PageReq pageReq) {
        PageResp<OrderModel> pageResp = orderService.findAll(orderQueryModel, pageReq);
        return pageResp;
    }

    @PutMapping("/receive/{id}")
    @ApiOperation("确认收货")
    public void receive(@PathVariable Long id) {
        orderService.receive(id);
    }

    @PutMapping("/send/{id}/{expressNo}")
    @ApiOperation("发货")
    public void send(@PathVariable Long id, @PathVariable String expressNo) {
        orderService.send(id, expressNo);
    }

    @PutMapping("/close/{id}")
    @ApiOperation("关闭订单")
    public void close(@PathVariable Long id) {
        orderService.close(id);
    }
}
